package com.moneytree.service.impl;

import java.util.List;

import com.moneytree.model.User;
import com.moneytree.service.UserService;
import com.moneytree.utils.Page;
import com.moneytree.utils.PersistenceUtils;

public class UserServiceImpl extends PersistenceUtils<User, String> implements UserService {

	@Override
	public User queryById(String id) {
		return get(id);
	}

	@Override
	public void saveOrUpdate(User user) {
		super.save(user);
	}

	@Override
	public void delete(User user) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public User queryUser(User user) {
		return query(user);
	}

	@Override
	public Page queryBean(User user, Page page) {
		int start = Page.countOffset(page.getPageSize(), page.getCurrentPage());
		int allCount = super.count(user);
		List<User> list = super.queryList(user, start, page.getPageSize());
		return Page.toPage(list, page.getCurrentPage(), page.getPageSize(), allCount);
	}

}
